 //
//  WWebViewController.m
//  Hxcsfw
//
//  Created by 企友软mac on 2017/11/17.
//  Copyright © 2017年 企友软mac. All rights reserved.
//

#import "WWebViewController.h"
#import "LoginViewController.h"
#import "CheckNetwork.h"
#import "CommentViewController.h"
#import "IQKeyboardManager.h"

@interface WWebViewController ()<UIWebViewDelegate, UITextViewDelegate> {
    UITextView *_textView;
    UIButton *fsBtn;
}

@property (strong, nonatomic) UIWebView *webView;
@property (nonatomic, copy)NSString *strSummary;//概要
@property (nonatomic, copy)NSString *strImage;//图片

@property (weak, nonatomic) IBOutlet UIImageView *imgCommentNum;
@property (weak, nonatomic) IBOutlet UIButton *btnInput;

@property (nonatomic, strong) UIView *inputView;
@property (nonatomic, strong) UILabel *lbOfPlaceholder;
@property (nonatomic, strong) UIButton *btnSend;

@end

@implementation WWebViewController

- (UIWebView *)webView {
    self.title = _strTitle;
    if (_webView == nil) {

        if ([WShareUtil strNilOrEmpty:_strID]) {
             _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        } else {
            _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT -49 -64)];
        }

        _webView.scrollView.bounces = NO;
        _webView.delegate = self;
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_strUrl]];
        [_webView loadRequest:request];
        [WShareUtil showWait:YES frame:CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64)];
        _webView.scalesPageToFit = YES;
    }
    return _webView;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self requestListDataStrNum:@"1" isRefresh:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [WShareUtil sharedData].isShowWait = YES;
    _btnInput.layer.cornerRadius = 15;
    _btnInput.clipsToBounds = YES;

    _textView.delegate = self;
    _imgCommentNum.hidden = YES;

    CheckNetwork *checkNetwork = [[CheckNetwork alloc] init];

    if (![checkNetwork isNetworkReachable]) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"no_web@2x.png"]];
        //imageView.frame = CGRectMake(20, WSCREENH_HEIGHT - 150, 80, 100);
        //360+416
        imageView.frame = CGRectMake(WSCREENH_WIDTH/2-75, WSCREENH_HEIGHT/2-88, 150, 175);
        [self.view addSubview:imageView];
    } else {
        [self.view addSubview:self.webView];
    }
    
    //对故障修复、征期清卡、操作指引、升级说明的分享做特殊处理
    if ([_strTitle isEqualToString:@"故障修复"]||[_strTitle isEqualToString:@"征期清卡"]||[_strTitle isEqualToString:@"操作指引"]||[_strTitle isEqualToString:@"升级说明"]||[_strTitle isEqualToString:@"办税日历"]) {

        //请求分享用到的字段(特殊处理)
        [self NewloadShareData];
    }else {
        _strSummary = _strTitle;//概要初始化也为标题
    }

    _strImage = [NSString string];//图片初始化

    if (![WShareUtil strNilOrEmpty:self.strID]||![WShareUtil strNilOrEmpty:self.strType]) { //如果strID和strType不为空，说明传参数了，请求下信息

        //请求分享用到的字段
        [self loadShareData];
    }

    //左按钮
    UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 40)];
    [leftBtn setImage:[UIImage imageNamed:@"back_icon.png"] forState:UIControlStateNormal];
    leftBtn.imageEdgeInsets = UIEdgeInsetsMake(10, 0, 10, 48);
    [leftBtn addTarget:self action:@selector(leftBtnClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    
    if (![WShareUtil strNilOrEmpty:self.shareTitle]) {//传了分享标题，则显示分享按钮
        // 右上角分享按钮
        [self loadRightBtn];
    }

    [IQKeyboardManager sharedManager].enable = NO;
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    _inputView = [[UIView alloc]initWithFrame:CGRectMake(0, WSCREENH_HEIGHT, WSCREENH_WIDTH, 49)];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wkeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wkeyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
}

#pragma mark - 请求分享用到的字段
-(void)loadShareData {

    if ([WShareUtil strNilOrEmpty:self.strID]) {
        self.strID = @"";
    }
    if ([WShareUtil strNilOrEmpty:self.strType]) {
        self.strType = @"";
    }
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"shareinfo",@"content":@{@"id":self.strID,@"type":self.strType}};

    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {

        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        //分享摘要
        if ([WShareUtil strNilOrEmpty:returnDic[@"summary"]]) {
            _strSummary = @"";
        }else{
            _strSummary = returnDic[@"summary"];
        }
        //分享图片
        if ([WShareUtil strNilOrEmpty:returnDic[@"img"]]) {
            _strImage = @"";
        }else{
            _strImage = returnDic[@"img"];
        }
        
    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:NO];
}

- (void)loadRightBtn {
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn2 setImage:[UIImage imageNamed:@"more.png"] forState:UIControlStateNormal];
    btn2.frame = CGRectMake(0, 0, 30, 30);
    [btn2 addTarget:self action:@selector(rightClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *barBtn2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
    self.navigationItem.rightBarButtonItem = barBtn2;

}

- (void)leftBtnClick {

    if (_isQr) {
        [self.navigationController popToRootViewControllerAnimated:YES];
    } else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)rightClick:(UIButton *)btn {
    
    WLog(@"%@",self.strUrl);
    WLog(@"%@",self.shareTitle);
    WLog(@"%@",self.strID);
    WLog(@"%@",self.strType);

    //对故障修复、征期清卡、操作指引、升级说明的分享做特殊处理
    if ([_strTitle isEqualToString:@"故障修复"]||[_strTitle isEqualToString:@"征期清卡"]||[_strTitle isEqualToString:@"操作指引"]||[_strTitle isEqualToString:@"升级说明"]||[_strTitle isEqualToString:@"办税日历"]) {

    }else {
        NSString *theLast = [self.strUrl substringFromIndex:[self.strUrl length]-1];
        if (![theLast isEqualToString:@"?"]) {
            self.strUrl = [self.strUrl stringByAppendingString: @"?"];
        }
    }


    [UMSocialUIManager setPreDefinePlatforms:@[@(UMSocialPlatformType_WechatSession),@(UMSocialPlatformType_WechatTimeLine),@(UMSocialPlatformType_QQ),@(UMSocialPlatformType_Qzone)]];
    // --- 设置分享面板的UI
    [UMSocialShareUIConfig shareInstance].shareTitleViewConfig.isShow = YES;//有无标题
    [UMSocialShareUIConfig shareInstance].shareCancelControlConfig.isShow = YES;//有无取消
    [UMSocialShareUIConfig shareInstance].shareTitleViewConfig.shareTitleViewTitleString = @"";//标题文字
    [UMSocialShareUIConfig shareInstance].shareCancelControlConfig.shareCancelControlText = @"取消";//取消文字
    [UMSocialShareUIConfig shareInstance].sharePageScrollViewConfig.shareScrollViewPageMaxItemWidth = 50;//每页Items的最大宽度(白圈的大小)
    [UMSocialShareUIConfig shareInstance].sharePageScrollViewConfig.shareScrollViewPageMaxItemHeight = 90;//每页Items的最大高度(背景的高低)
    
    [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
        // 根据获取的1确定所选平台进行下一步操作
        /*
         详情
         */
        NSString *descrStr = [WShareUtil filterHTML:_strSummary];
        descrStr = [descrStr stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];//去掉特殊符号
        descrStr = [descrStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];//去掉左右两端的空格
        /*
         图片
         */
        NSURL *imgUrl = [NSURL URLWithString:_strImage];
        NSData *dateImg = [NSData dataWithContentsOfURL:imgUrl];
        
        if (dateImg == nil || dateImg.length <= 0) {
            UMShareWebpageObject *webO = [UMShareWebpageObject shareObjectWithTitle:self.shareTitle descr:descrStr thumImage:[UIImage imageNamed:@"logo_share.png"]];
            
            if ([self.strUrl isEqualToString:@"http://www.sx95113.com/wapfww/azsm"]) { //安装说明
                webO.webpageUrl = [NSString stringWithFormat:@"%@?source=zst",self.strUrl];
            }else{
                webO.webpageUrl = [NSString stringWithFormat:@"%@&source=zst",self.strUrl];
            }
            
            [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:[UMSocialMessageObject messageObjectWithMediaObject:webO] currentViewController:self completion:^(id result, NSError *error) {
                
                NSString *message = nil;
                if (!error) {
                    message = [NSString stringWithFormat:@"分享成功"];
                } else {
                    message = [NSString stringWithFormat:@"失败原因Code: %d\n",(int)error.code];
                }
            }];
        } else {
            UMShareWebpageObject *webO = [UMShareWebpageObject shareObjectWithTitle:self.shareTitle descr:descrStr thumImage:dateImg];

            if ([self.strUrl isEqualToString:@"http://www.sx95113.com/wapfww/azsm"]) { //安装说明
                webO.webpageUrl = [NSString stringWithFormat:@"%@?source=zst",self.strUrl];
            }else{
                webO.webpageUrl = [NSString stringWithFormat:@"%@&source=zst",self.strUrl];
            }
            
            [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:[UMSocialMessageObject messageObjectWithMediaObject:webO] currentViewController:self completion:^(id result, NSError *error) {
                
                NSString *message = nil;
                if (!error) {
                    message = [NSString stringWithFormat:@"分享成功"];
                } else {
                    message = [NSString stringWithFormat:@"失败原因Code: %d\n",(int)error.code];
                    
                }
            }];
        }
    }];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {//加载完成
    [WShareUtil showWait:NO frame:CGRectZero];

    if ([self.strTitle isEqualToString:@"95113服务网"]) {


    } else if ([self.strTitle isEqualToString:@"问吧详情"]){

        NSString *strAbsoluteUrl = self.webView.request.URL.absoluteString;
        WLog(@"%@", strAbsoluteUrl);

        if ([strAbsoluteUrl rangeOfString:@"http://www.sobot.com/chat/h5/index.html?sysNum="].location != NSNotFound ) {
            _webView.frame = CGRectMake(0, 64, WSCREENH_WIDTH, WSCREENH_HEIGHT - 64);
        }
    }

}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {//加载失败/错误
    [WShareUtil showWait:NO frame:CGRectZero];
}

- (void)viewWillDisappear:(BOOL)animated {//视图将要消失
    [WShareUtil showWait:NO frame:CGRectZero];
}

#pragma mark - 请求分享用到的字段(特殊处理)
-(void)NewloadShareData {
    
    NSDictionary *parametersDict = @{@"mode":@"native",@"service":@"shareinfo",@"content":@{@"from":self.from,@"type":@"custom"}};
    
    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};
    
    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        //分享摘要
        if ([WShareUtil strNilOrEmpty:returnDic[@"summary"]]) {
            _strSummary = @"";
        }else{
            _strSummary = returnDic[@"summary"];
        }
        //分享图片
        if ([WShareUtil strNilOrEmpty:returnDic[@"img"]]) {
            _strImage = @"";
        }else{
            _strImage = returnDic[@"img"];
        }

        if ([WShareUtil strNilOrEmpty:returnDic[@"link"]]) {
            _strUrl = @"";
        }else{
            _strUrl = returnDic[@"link"];
        }
        
    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:NO];
}

- (IBAction)commentViewBtnClick:(UIButton *)sender {

    if (sender.tag == 2) {
        if (![WShareUtil strNilOrEmpty:self.shareTitle]) {
            [self rightClick:nil];
        }
    } else if (sender.tag == 1){
        CommentViewController *commentVc = [[CommentViewController alloc] init];
        commentVc.strID = self.strID;
        commentVc.shareTitle = self.shareTitle;
        commentVc.strType = self.strType;
        commentVc.strUrl = self.strUrl;
        [self.navigationController pushViewController:commentVc animated:YES];
    } 
}


-(void)wkeyboardWillShow:(NSNotification *)notification
{
    //这样就拿到了键盘的位置大小信息frame，然后根据frame进行高度处理之类的信息
    CGRect frame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

    CGFloat endHeight = WSCREENH_HEIGHT - self.inputView.bounds.size.height - frame.size.height;

    _inputView.frame = CGRectMake(0, endHeight, WSCREENH_WIDTH, 49);
    //    _textView.text = _textViewQ.text;
    if ([_textView.text length] == 0) {
        [self.lbOfPlaceholder setHidden:NO];
        [fsBtn setUserInteractionEnabled:NO];
        //        [fsBtn setBackgroundColor:[UIColor grayColor]];

    }else {
        [self.lbOfPlaceholder setHidden:YES];
        [fsBtn setUserInteractionEnabled:YES];
        //        [fsBtn setBackgroundColor:[UIColor colorWithRed:0.09 green:0.69 blue:0.11 alpha:1]];
    }

}

/**
 *  键盘将要隐藏
 *
 *  @param notification 通知
 */
-(void)wkeyboardWillHidden:(NSNotification *)notification
{
    _inputView.frame = CGRectMake(0, WSCREENH_HEIGHT, WSCREENH_WIDTH, 49);
    UIView *bgView = [self.view viewWithTag:20000];
    [bgView removeFromSuperview];
    [self.btnSend setBackgroundImage:[UIImage imageNamed:@"fabiao2"] forState:UIControlStateNormal];
    [self.btnSend setUserInteractionEnabled:NO];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

    [_textView resignFirstResponder];
    UIView *bgView = [self.view viewWithTag:20000];
    [bgView removeFromSuperview];

}

- (void)textViewDidChange:(UITextView *)textView {
    NSUInteger length = [textView.text length];
    NSRange range = NSMakeRange(length - 1, 1);
    if([[textView.text substringWithRange:range] isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
    }
    // 该判断用于联想输入, 限制输入字数500
    if (textView.text.length > 499 ) {
        _textView.text = [textView.text substringToIndex:500];
    }

    if ([textView.text length] == 0) {
        [self.lbOfPlaceholder setHidden:NO];
        [fsBtn setUserInteractionEnabled:NO];
        //        [fsBtn setBackgroundColor:[UIColor grayColor]];

    }else {
        [self.lbOfPlaceholder setHidden:YES];
        [fsBtn setUserInteractionEnabled:YES];
        //        [fsBtn setBackgroundColor:[UIColor colorWithRed:0.09 green:0.69 blue:0.11 alpha:1]];
    }
}

- (IBAction)inputTextBtnClick:(UIButton *)sender {
    UIView *bgView = [[UIView alloc]initWithFrame:self.view.bounds];
    bgView.backgroundColor = [UIColor grayColor];
    bgView.alpha = 0.4;
    bgView.tag = 20000;
    [self.view addSubview:bgView];

    _inputView.backgroundColor = [UIColor whiteColor];

    [self.view addSubview:_inputView];

    _textView = [[UITextView alloc]initWithFrame:CGRectMake(20, 9, WSCREENH_WIDTH - 20 - 80, 31)];
    _textView.layer.masksToBounds = YES;
    _textView.layer.cornerRadius = 15;
    _textView.delegate = self;
    _textView.backgroundColor = WRGBColor(239, 240, 241);
    _textView.textContainerInset = UIEdgeInsetsMake(7, 8, 0, 0);
    _textView.font = [UIFont systemFontOfSize:15];
    [_inputView addSubview:_textView];

    [_textView becomeFirstResponder];

    //    _textView.inputAccessoryView = nil;
    self.lbOfPlaceholder = [[UILabel alloc]initWithFrame:CGRectMake(35, 9, 120, 31)];
    self.lbOfPlaceholder.enabled = NO;
    self.lbOfPlaceholder.text = @"期待您的评论";
    self.lbOfPlaceholder.font = [UIFont systemFontOfSize:12];
    self.lbOfPlaceholder.textColor = WRGBColor(150, 150, 150);
    [_inputView addSubview:self.lbOfPlaceholder];

    // 限制500字内容
    //    self.lbWBZContent = [[UILabel alloc]initWithFrame:CGRectMake(20, 95, 200, 21)];
    //    self.lbWBZContent.enabled = NO;
    //    self.lbWBZContent.text = @"限制500字内容";
    //    self.lbWBZContent.font = [UIFont systemFontOfSize:12];
    //    self.lbWBZContent.textColor = [UIColor greenColor];
    //    [_inputView addSubview:self.lbWBZContent];

    //发送按钮
    fsBtn = [[UIButton alloc]initWithFrame:CGRectMake(WSCREENH_WIDTH - 70, 9, 60, 31)];
    [fsBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [fsBtn setTitle:@"发布" forState:UIControlStateNormal];
    [fsBtn setUserInteractionEnabled:NO];
    [fsBtn setTitleColor:WRGBColor(88, 131, 251) forState:UIControlStateNormal];
    //    [fsBtn setTintColor:[UIColor whiteColor]];
    //    [fsBtn setBackgroundColor:[UIColor grayColor]];
    [fsBtn addTarget:self action:@selector(fsClick) forControlEvents:UIControlEventTouchUpInside];

    [_inputView addSubview:fsBtn];
}

-(void)fsClick {
    WLog(@"上发送");
    WLog(@"%@",_textView.text);
    // 判断输入内容是否有表情，有则不能提交
    if ([_textView.text stringContainsEmoji:_textView.text]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"评论内容暂不支持表情" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        _textView.text = @"";
        return;
    }

    if ([_textView.text disable_emoji:_textView.text]) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"评论内容暂不支持表情" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        _textView.text = @"";
        return;
    }

    [self requestDataSubmitComment];
    [[IQKeyboardManager sharedManager] doneAction:nil];
}

#pragma mark - 提交评论
-(void)requestDataSubmitComment {
    /*
     mode:native,service:comment,content:{revert:submit,username:？,dto:{from:xt,id:?,content=?}}
     */
    NSString *username;
    NSDictionary *parametersDict;
    NSString *nologinuser = [WShareUtil getUUID];
    if ([WShareUtil sharedData].dicSession) {
        username = [WShareUtil sharedData].dicSession[@"nsrsbh"];
        if (username == nil) {
            username = @"";
        }
        parametersDict = @{@"mode":@"native",@"service":@"comment",@"content":@{@"revert":@"submit",@"username":[WShareUtil sharedData].dicSession[@"nsrsbh"],@"dto":@{@"from":@"fwwb",@"id":_strID,@"content":_textView.text}}};
    }else {
        parametersDict = @{@"mode":@"native",@"service":@"comment",@"content":@{@"revert":@"submit",@"nologinuser":nologinuser,@"dto":@{@"from":@"fwwb",@"id":_strID,@"content":_textView.text}}};
    }

    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};

    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {
        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        if([returnDic[@"resultCode"] isEqualToString:@"SUCCEED"]){

            //            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE message:@"评论提交成功！" delegate:nil cancelButtonTitle:SURE otherButtonTitles:nil];
            //            [alert show];
            //            return;
            CommentViewController *commentVc = [[CommentViewController alloc] init];
            commentVc.strID = self.strID;
            commentVc.shareTitle = self.shareTitle;
            commentVc.strType = self.strType;
            commentVc.strUrl = self.strUrl;
            [self.navigationController pushViewController:commentVc animated:YES];

        }else if([returnDic[@"resultCode"] isEqualToString:@"DTO_ERROR"]){

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE message:@"提交数据格式错误！" delegate:nil cancelButtonTitle:SURE otherButtonTitles:nil];
            [alert show];
            return;
        }

    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:YES];
}

- (void)requestListDataStrNum:(NSString *)pageNum isRefresh:(BOOL)isRefresh{

    NSString *username;
    NSString *nologinuser = [WShareUtil getUUID];
    if ([WShareUtil strNilOrEmpty:_strID]) {
        _strID = @"";
    }

    NSDictionary *parametersDict;
    if ([WShareUtil sharedData].dicSession) {
        username = [WShareUtil sharedData].dicSession[@"nsrsbh"];
        if (username == nil) {
            username = @"";
        }
        parametersDict = @{@"mode":@"native",@"service":@"comment",@"content":@{@"username":[WShareUtil sharedData].dicSession[@"nsrsbh"],@"revert":@"paginate",@"from":@"fwwb",@"id":_strID,@"pagesize":@"10",@"pagenumber":pageNum,@"apptype":@"ios"}};
    }else {
        parametersDict = @{@"mode":@"native",@"service":@"comment",@"content":@{@"nologinuser":nologinuser,@"revert":@"paginate",@"from":@"fwwb",@"id":_strID,@"pagesize":@"10",@"pagenumber":pageNum,@"apptype":@"ios"}};
    }

    NSString *secret = [NSString stringWithFormat:@"%@",[WHttpTool convertToJsonData:parametersDict]];
    //    NSDictionary *paramsDic = @{@"params":[CommonFunc encryptWithText:secret]};

    [WHttpTool POST:[WShareUtil getServerURL:nil] parameters:@{@"params":[CommonFunc encryptWithText:secret]} success:^(id responseObject) {

        NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSDictionary *JsonDic = [WHttpTool dictionaryWithJsonString:responseStr];
        NSString *messageStr = [JsonDic objectForKey:@"message"];
        NSString *successStr = [JsonDic objectForKey:@"success"];
        // 解密请求回的数据（字典）
        NSString *returnStr = [CommonFunc decryptWithText:messageStr];

        // json字符串转字典
        NSDictionary *returnDic = [WHttpTool dictionaryWithJsonString:returnStr];

        if ([returnDic[@"data"] count] > 0) {
            _imgCommentNum.hidden = NO; 
        }

    } failure:^(NSError *error) {
        WLog(@"失败");
    } showProgress:YES];
}

@end
